#建表参考
DROP TABLE IF EXISTS `yr_member`;
CREATE TABLE `yr_member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`openid` varchar(50) NOT NULL DEFAULT '' COMMENT 'openid',
`avatar` varchar(255) DEFAULT NULL COMMENT '用户图像',
`username` varchar(32) NOT NULL DEFAULT '' COMMENT '用户名',
`nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
`mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`level` tinyint(1)  NOT NULL DEFAULT '0' COMMENT '等级',
`gender` tinyint(1)  NOT NULL DEFAULT '0' COMMENT '性别',
`birthday` int(11) DEFAULT NULL COMMENT '生日',
`credit` float(11,2) NOT NULL DEFAULT '0' COMMENT '积分',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户表';
php think crud -t cw_discountlog -r serviceorder -r discount -r member -k oid -k discountid -k openid  -p id -p id -p openid -c discount/discountlog -u 1


20190102
#用户表
DROP TABLE IF EXISTS `wr_member`;
CREATE TABLE `wr_member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`openid` varchar(50) NOT NULL DEFAULT '' COMMENT 'openid',
`avatar_image` varchar(255) DEFAULT NULL COMMENT '图像',
`username` varchar(32) NOT NULL DEFAULT '' COMMENT '用户名',
`nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
`mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`agentid` int(10) NOT NULL DEFAULT '0' COMMENT '上级id',
`identity` enum('1','2','3','4','5') DEFAULT NULL COMMENT '身份:1=事业合伙人,2=销售合伙人,3=会员,4=自费会员,5=其他',
`membersn` varchar(50) NOT NULL DEFAULT '5' COMMENT '编号',
`p_id` int(10) NOT NULL DEFAULT '0' COMMENT '合伙人分类id',
`credit` float(11,2) NOT NULL DEFAULT '0.00' COMMENT '积分',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户列表';


php think crud  -t wr_member -r partner -k p_id  -c  member/member -u 1

#事业合伙人分类
DROP TABLE IF EXISTS `wr_partner`;
CREATE TABLE `wr_partner` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='事业合伙人分类';

php think crud  -t wr_partner  -c  member/partner -u 1

#幻灯片
DROP TABLE IF EXISTS `wr_slide`;
CREATE TABLE `wr_slide` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`images` varchar(255) DEFAULT NULL COMMENT '图像',
`is_default` enum('1','2') DEFAULT NULL COMMENT '默认使用:1=使用,2=不使用',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='幻灯片';

php think crud  -t wr_slide  -c  image/slide -d 1
php think crud  -t wr_slide  -c  image/slide -u 1

#广告表图片
DROP TABLE IF EXISTS `wr_adver`;
CREATE TABLE `wr_adver` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`images` varchar(255) DEFAULT NULL COMMENT '图像',
`url` varchar(255) DEFAULT NULL COMMENT '跳转路径',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='广告表图片';

php think crud  -t wr_adver  -c  image/adver -d 1
php think crud  -t wr_adver  -c  image/adver -u 1

#公告
DROP TABLE IF EXISTS `wr_notice`;
CREATE TABLE `wr_notice` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`content` text COMMENT '内容',
`url` varchar(255) DEFAULT NULL COMMENT '跳转路径',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='公告';

php think crud  -t wr_notice  -c  image/notice -u 1


#会员规则表
DROP TABLE IF EXISTS `wr_member_rules`;
CREATE TABLE `wr_member_rules` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`money` float(11,2) NOT NULL DEFAULT '0' COMMENT '金额',
`describe` text COMMENT '会员描述',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员规则表';

php think crud  -t wr_member_rules  -c  rules/memberrules -d 1


#购买会员记录
DROP TABLE IF EXISTS `wr_memberlog`;
CREATE TABLE `wr_memberlog` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '记录id',
`openid` varchar(50) DEFAULT NULL COMMENT 'openid',
`logsn` varchar(50) DEFAULT NULL COMMENT '订单编号',
`price` varchar(10) DEFAULT NULL COMMENT '金额',
`status` enum('0','1') NOT NULL COMMENT '支付状态:0=未支付,1=支付',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员购买记录';

php think crud  -t wr_memberlog  -c  member/memberlog -u 1


#折扣规则
DROP TABLE IF EXISTS `wr_disrule`;
CREATE TABLE `wr_disrule` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`rule` varchar(50) NOT NULL DEFAULT '0' COMMENT '规则',
`color` enum('1','2','3','4','5') DEFAULT '5' COMMENT '颜色:1=red,2=yellow,3=purple,4=green,5=white',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='折扣规则';

php think crud  -t wr_disrule  -c  rules/disrule -u 1


#优惠券表
DROP TABLE IF EXISTS `wr_discount`;
CREATE TABLE `wr_discount` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(50) DEFAULT NULL COMMENT '优惠券名称',
`full` float(11,2) NOT NULL DEFAULT '0' COMMENT '满额',
`money` float(11,2) NOT NULL DEFAULT '0' COMMENT '抵用金额',
`endtime` int(12) DEFAULT NULL COMMENT '到期时间',
`createtime` int(12) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='优惠券';

php think crud  -t wr_discount  -c  discount/discount -u 1

#用户优惠券
DROP TABLE IF EXISTS `wr_userdiscount`;
CREATE TABLE `wr_userdiscount` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`openid` varchar(50) DEFAULT NULL COMMENT 'openid',
`discount_id` int(10) NOT NULL DEFAULT '0' COMMENT '优惠券id',
`verify` varchar(50) DEFAULT NULL COMMENT '核销码',
`status` enum('1','2') DEFAULT '2' COMMENT '使用状态:1=已使用,2=未使用',
`verifytime` int(12) DEFAULT NULL COMMENT '使用时间',
`createtime` int(12) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户优惠券';

php think crud -t wr_userdiscount -r member -r discount  -k openid -k  discount_id -c  discount/user -u 1

#优惠券核销记录(暂无订单表,该表没有建立)
DROP TABLE IF EXISTS `wr_verify`;
CREATE TABLE `wr_verify` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`openid` varchar(50) DEFAULT NULL COMMENT 'openid',
`discount_id` int(10) NOT NULL DEFAULT '0' COMMENT '优惠券id',
`order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单id',
`createtime` int(12) DEFAULT NULL COMMENT '核销时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户优惠券';

php think crud -t wr_userdiscount -r member -r discount  -k openid -k  discount_id -c  discount/user -u 1


#卡斯摩门店
DROP TABLE IF EXISTS `wr_store`;
CREATE TABLE `wr_store` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`intro` text COMMENT '简介',
`longitude` varchar(80) DEFAULT NULL COMMENT '经度',
`latitude` varchar(80) DEFAULT NULL COMMENT '纬度',
`address` varchar(255) DEFAULT NULL COMMENT '地址',
`mobile` varchar(11) NOT NULL DEFAULT '0' COMMENT '电话',
`createtime` int(12) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='门店';

php think crud -t wr_store  -c  store/store -u 1


#商品类型
DROP TABLE IF EXISTS `wr_gtype`;
CREATE TABLE `wr_gtype` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(255) DEFAULT NULL COMMENT '名称',
`image` varchar(255) DEFAULT NULL COMMENT '图片',
`createtime` int(12) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='商品类型';

php think crud -t wr_gtype  -c  goods/gtype -u 1

#商品表
DROP TABLE IF EXISTS `wr_goods`;
CREATE TABLE `wr_goods` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`mprice` float(11,2) NOT NULL DEFAULT '0.00' COMMENT '市场价',
`gprice` float(11,2) NOT NULL DEFAULT '0.00' COMMENT '商品价',
`pprice` float(11,2) NOT NULL DEFAULT '0.00' COMMENT '会员价',
`image` varchar(255) DEFAULT NULL COMMENT '缩略图',
`images` varchar(255) DEFAULT NULL,
`gtype_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品类型',
`pdata` enum('1','2') DEFAULT NULL COMMENT '商品分类:1=天天特价,2=一元抢购',
`describe` text COMMENT '描述',
`longitude` varchar(80) DEFAULT NULL COMMENT '经度',
`latitude` varchar(80) DEFAULT NULL COMMENT '纬度',
`address` varchar(255) DEFAULT NULL COMMENT '地址',
`num` int(11) NOT NULL DEFAULT '0' COMMENT '数量',
`volume` int(11) DEFAULT NULL COMMENT '自定义销量',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='商品表';

php think crud -t wr_goods -r gtype -k gtype_id  -c  goods/goods -d 1
php think crud -t wr_goods -r gtype -k gtype_id  -c  goods/goods -u 1


#订单表
DROP TABLE IF EXISTS `wr_order`;
CREATE TABLE `wr_order` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`openid` varchar(80) DEFAULT NULL COMMENT '编号',
`ordersn` varchar(255) DEFAULT NULL COMMENT '编号',
`agentid` int(10) NOT NULL DEFAULT '0' COMMENT '购买者上级',
`price` float(11,2) NOT NULL DEFAULT '0' COMMENT '价格',
`discount_id` int(10)  DEFAULT NULL COMMENT '优惠券',
`commission` float(11,2) NOT NULL DEFAULT '0' COMMENT '佣金',
`status` enum('-1','1') DEFAULT NULL COMMENT '状态:1=已支付,-1=退款',
`statis` enum('1','0')  NOT NULL DEFAULT '0' COMMENT '状态:0=未统计,1=已统计',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='订单列表';

php think crud -t wr_order -r member -r discount -k openid  -k discount_id -c  order/order -d 1

php think crud -t wr_order -r member -r discount -k openid  -k discount_id -c  order/order -u 1


#订单商品表
DROP TABLE IF EXISTS `wr_order_goods`;
CREATE TABLE `wr_order_goods` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`order_id` int(10) NOT NULL DEFAULT '0' COMMENT '订单id',
`name` varchar(255) DEFAULT NULL COMMENT '商品名称',
`gtype_id` int(10) NOT NULL DEFAULT '0' COMMENT '商品类型',
`dis_id` int(10) NOT NULL DEFAULT '0' COMMENT '折扣id',
`price` float(11,2) NOT NULL DEFAULT '0' COMMENT '价格',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='订单列表';

php think crud -t wr_order_goods -r order -r gtype -r disrule -k order_id  -k gtype_id -k dis_id  -c  order/ordergoods -d 1
php think crud -t wr_order_goods -r order -r gtype -r disrule  -k order_id  -k gtype_id  -k dis_id  -c  order/ordergoods -u 1


#积分抵用规则
DROP TABLE IF EXISTS `wr_contrast`;
CREATE TABLE `wr_contrast` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`credit` int(10)  NOT NULL  COMMENT '积分',
`ratio` int(10)  NOT NULL  COMMENT '金额',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='积分抵用规则';

php think crud  -t wr_contrast  -c  rules/contrast -d 1
php think crud  -t wr_contrast  -c  rules/contrast -u 1


#获取积分规则
DROP TABLE IF EXISTS `wr_integral`;
CREATE TABLE `wr_integral` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`rule` int(10)  NOT NULL  COMMENT '规则',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='获取积分规则';

php think crud  -t wr_integral  -c  rules/integral -u 1


#绑定时间规则
DROP TABLE IF EXISTS `wr_bind`;
CREATE TABLE `wr_bind` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`residue` int(10)  NOT NULL  COMMENT '剩余时间',
`bind` int(10)  NOT NULL  COMMENT '绑定时间',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='绑定时间规则';

php think crud  -t wr_bind  -c  rules/bind -u 1







































